<?php

if(!isset($_SESSION)) session_start();
if (!isset($_SESSION['f_user_id'])) {
	echo 'Access denied!';
} else {

	$form = f()->form('add_classroom','New classroom')
		->text('name',t('Name'))
		->text('password',t('Password'))
		->text('description',t('Description'),array(
			'rows' => 5,
		))
		->button('submit',t('Create'));
	
	if ($form->submitted()) {
		$fields = array('name','password','description');
		$o = $this->db()->create('classroom','Classroom');
		$form->load();
		$form->save($o,$fields);
		$o->save();
		$this->redirect('@classroom/'.$o->_f_pkey_);
	} else {
		$form->render();
	}

}